package com.wnx.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;


import com.opensymphony.xwork2.ActionSupport;
import com.wnx.db.PurDao;
import com.wnx.entity.Purchase;

public class PurchaseBuyAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private Purchase p;
	

    public Purchase getP() {
		return p;
	}


	public void setP(Purchase p) {
		this.p = p;
	}


	public String execute()  
    {  
        
        Purchase purchase = new Purchase();
		purchase.setName(p.getName());
		purchase.setIntroduce(p.getIntroduce());
		purchase.setSid(p.getSid());
		purchase.setMid(p.getMid());
		purchase.setAddress(p.getAddress());
		purchase.setUid(p.getUid());
		purchase.setPhone(p.getPhone());
		purchase.setQq(p.getQq());
		purchase.setPrice(p.getPrice());
		purchase.setState(0);
		Date now = new Date(); 
		SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
		String date = sdf.format( now ); 
		purchase.setDate(date);
		PurDao pd = new PurDao();  
		pd.saveP(purchase);
        return SUCCESS;  
    } 
}
